package com.song.estore.utils;

import java.security.MessageDigest;

/**
 * Created by 范姣姣 on 2015/10/22.
 */
public class MD5Utils {

    public static String getPassword( String password ){
        StringBuilder sb = new StringBuilder();
        try{
            MessageDigest digest = MessageDigest.getInstance("MD5");
            byte[] bs = digest.digest(password.getBytes());
            for (byte b : bs) {
                int x = b & 255;
                if( x < 16 && x >= 0){
                    sb.append("0");
                    sb.append(Integer.toHexString(x));
                }else{
                    sb.append(Integer.toHexString(x));
                }
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return sb.toString();

    }
}
